package com.gs.synedocket.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.gs.synedocket.R;
import com.gs.synedocket.constant.AllConstants;
import com.gs.synedocket.util.AppUtil;
import com.gs.synedocket.util.SPUtil;
import com.gs.synedocket.util.WindowUtil;

public class WelcomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        if (!isTaskRoot()) {
            finish();
            return;
        }
        WindowUtil.getInstance().setBarBgColor(this, R.color.bar_color);
        TextView tvVersion = findViewById(R.id.tv_version);
        tvVersion.setText(String.format("V%s", AppUtil.getInstance().getVersion()));
        new Handler(getMainLooper()).postDelayed(() -> {
            if (TextUtils.isEmpty(SPUtil.getInstance().getString(AllConstants.TOKEN))) {
                startActivity(new Intent(WelcomeActivity.this, LoginActivity.class));
            } else {
                startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
            }
            finish();
        }, 3000);
    }
}